import React from "react";
import { Route, Switch } from "react-router";

const renderRouter = (
  routers: RouterConfig[],
) =>
  routers ? (
    <Switch>
      {routers.map((route: RouterConfig, i: number) => (
        <Route
          key={route.path || i}
          path={route.path}
          exact={route.exact}
          component={route.component}
        />
      ))}
    </Switch>
  ) : null;

export default renderRouter;
